package vip.xiaonuo.smzq.modular.kcl.controller;

import javax.annotation.Resource;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import vip.xiaonuo.smzq.modular.kcl.entity.Tkqsqdj;
import vip.xiaonuo.smzq.modular.kcl.service.ITkqsqdjService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 探矿权申请登记基本信息
 *
 * @author sqq
 * @since 2024-03-19
 */
@Api(tags = "探矿权申请登记基本信息")
@RestController
@RequestMapping("/kcl/tkqsqdj")
@Validated
public class TkqsqdjController {

    @Resource
    private ITkqsqdjService iTkqsqdjService;

    /**
     * 添加探矿权申请登记基本信息
     */
    @ApiOperation("添加探矿权申请登记基本信息")
    @PostMapping("/add")
    public CommonResult<String> add(@RequestBody @Valid Tkqsqdj tkqsqdj) {
        iTkqsqdjService.save(tkqsqdj);
        return CommonResult.ok();
    }

    /**
     * 删除探矿权申请登记基本信息
     */
    @ApiOperation("删除探矿权申请登记基本信息")
    @PostMapping("/delete")
    public CommonResult<String> delete(@ApiParam(name = "pkid", value = "主键") @RequestParam String pkid) {
        iTkqsqdjService.removeById(pkid);
        return CommonResult.ok();
    }

    /**
     * 编辑探矿权申请登记基本信息
     */
    @ApiOperation("编辑探矿权申请登记基本信息")
    @PostMapping("/edit")
    public CommonResult<String> edit(@RequestBody @Valid Tkqsqdj tkqsqdj) {
        iTkqsqdjService.updateById(tkqsqdj);
        return CommonResult.ok();
    }

    /**
     * 探矿权申请登记基本信息分页查询
     */
    @ApiOperation("探矿权申请登记基本信息分页查询")
    @GetMapping("/list")
    public CommonResult<Page<Tkqsqdj>> page() {
        return CommonResult.data(iTkqsqdjService.page(new Tkqsqdj()));
    }
    /**
     * 探矿权申请登记基本信息详情
     */
    @ApiOperation("探矿权申请登记基本信息详情")
    @GetMapping("/getTkqsqdj")
    public CommonResult<Tkqsqdj> getTkqsqdj(
            @ApiParam(name = "nd", value = "年度",  required = true) @RequestParam Integer nd,
            @ApiParam(name = "kqbm", value = "矿区编码",  required = true) @RequestParam String kqbm,
            @ApiParam(name = "djflbm", value = "登记分类编码",  required = true) @RequestParam Integer djflbm
    ) {
        return CommonResult.data(iTkqsqdjService.getTkqsqdj(djflbm, kqbm, nd));
    }
}
